<template>
  <div>
     <button @click="getData">点击获取后端数据</button>
  </div>
</template>

<script>
//   引入组件
import axios from "axios"
  export default {
    name: 'App',
    methods: {
      getData(){
        axios.get("http://localhost:8080/api/index/").then(
          response => {
            console.log("请求数据成功了", response.data)
          },
          error => {
            console.log("数据请求错误", error.message)
          }
        )
      }
    },
}
</script>






